// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.test;

import java.util.Date;

import javax.xml.xpath.XPathConstants;

import org.dengues.commons.jdk.xpath.ComplexXPathUsedXalan;
import org.dengues.commons.ui.swt.MergeComposite;
import org.dengues.commons.ui.swt.calendar.SWTCalendarDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf 1 2006-09-29 17:06:40Z qiang.zhang $
 * 
 */
public class CommonsTestAll {

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "main".
     * 
     * @param args
     */
    public static void main(String[] args) {
        // testSWT();
        testXPath();
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "testXPath".
     */
    private static void testXPath() {
        ComplexXPathUsedXalan complexXPath = new ComplexXPathUsedXalan("c:/SimpleNamespace.xml"); //$NON-NLS-1$
        String expression = "/a:main/node"; //$NON-NLS-1$
        try {
            NodeList nodes = (NodeList) complexXPath.parseXPath(expression, XPathConstants.NODESET);
            System.out.println("length: " + nodes.getLength()); //$NON-NLS-1$
            for (int i = 0; i < nodes.getLength(); i++) {
                Node item = nodes.item(i);
                System.out.println("Name:" + item.getNodeName() + " value:" + item.getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "testSWT".
     */
    private static void testSWT() {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new GridLayout());
        SWTCalendarDialog dialog = new SWTCalendarDialog(shell, new Date(), "Time"); //$NON-NLS-1$
        shell.setSize(600, 400);
        MergeComposite mergeComposite = new MergeComposite(shell, SWT.NONE);
        shell.open();
        dialog.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}
